package pathways.SpeciesSpace;

/**
 * Title:        Pathways
 * Description:  Pure Java version of the Pathways Project.
 * Copyright:    Copyright (c) 2002
 * Company:      Ants Technologies
 * @author Veejay Sani
 * @version 1.0
 */
import java.sql.ResultSet;
import java.sql.SQLException;

import pathways.Database.Implementation.CDatabase;
import pathways.util.Debug.CDebug;

public class CField
{
  private int ID;
  private String name;
  private String unit;
  
  public CField()
  {
    ID = 0;
    name = "";
    unit = "";
  }
  
  public int getID()
  {
    return ID; 
  }
  
  public void setID(int id)
  {
    ID = id; 
  }
  
  public String getName()
  {
    return name; 
  }
  
  public void setName(String fieldName)
  {
    name = fieldName; 
  }
  
  public String getUnit()
  {
    return unit; 
  }
  
  public void setUnit(String units)
  {
    unit = units;
  }
  
  public boolean read(int id, CDatabase db)
  {
    ResultSet rs = db.getSelect().getDataField(id);
    
    try {
      if (rs.next())
      {
        ID = rs.getInt(1);
        name = rs.getString(2);
        unit = rs.getString(3); 
      }      
    } catch (SQLException sqle) {
      CDebug.println(this,"read() Exception: " + sqle.toString());
      return false; 
    }
    
    return true;
  }
  
  public boolean save(CDatabase db)
  {
    return true; 
  }
}